﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AWZhome.awzBoxes.TestApp
{
	public class LayoutStorageTestProvider : ILayoutStorageProvider
	{
		private Dictionary<string, string> _boxItemConfigurations;
		private Dictionary<string, string> _generalConfigurations;
		private List<string> _lastOpenBoxItems;

		public LayoutStorageTestProvider()
		{
			_boxItemConfigurations = new Dictionary<string, string>();
			_generalConfigurations = new Dictionary<string, string>();
			_lastOpenBoxItems = new List<string>();
		}

		#region ILayoutStorageProvider Member

		public string GetBoxItemConfiguration(string boxItemName)
		{
			if (_boxItemConfigurations.ContainsKey(boxItemName))
			{
				return _boxItemConfigurations[boxItemName];
			}
			else
			{
				return null;
			}
		}

		public void SetBoxItemConfiguration(string boxItemName, string configuration)
		{
			// Implement this
			System.Windows.MessageBox.Show(configuration, boxItemName);

			_boxItemConfigurations[boxItemName] = configuration;
		}

		public string[] GetLastOpenBoxItems()
		{
			return _lastOpenBoxItems.ToArray();
		}

		public void SaveLastOpenBoxItems(string[] openBoxItems)
		{
			_lastOpenBoxItems.Clear();
			_lastOpenBoxItems.AddRange(openBoxItems);
		}

		public BoxItem RestoreBoxItem(string name)
		{
			if (name != "Fixed Window")
			{
				return new BoxItem()
				{
					Name = name,
					Title = name
				};
			}
			else
			{
				return null;
			}
		}

		public void SetGeneralConfiguration(string key, string value)
		{
			_generalConfigurations[key] = value;
		}

		public string GetGeneralConfiguration(string key)
		{
			if (_generalConfigurations.ContainsKey(key))
			{
				return _generalConfigurations[key];
			}
			else
			{
				return null;
			}
		}

		#endregion
	}
}
